"""
@author: yqx
@file: data_skill.py
@time: 2024/8/3 0:03
"""
"""
获取编号
"""

import data_get_url as geturl
import csv
import json

"""
获取城市编号
"""
#城市  https://www.zhipin.com/wapi/zpgeek/common/data/city/site.json
# urls="https://www.zhipin.com/wapi/zpgeek/common/data/city/site.json"
# text=geturl.download(urls)
#所有城市分类及编号
# datacity=json.loads(text)
# print(datacity)
# 获取热门城市编号
# hotcity=datacity["zpData"]["hotCitySites"]
# print(hotcity)
# for citys in hotcity:
#     print(citys)
#     print(citys["code"])
#     print("===================分隔符==============================")

"""
获取工作编号
"""

urls2="https://www.zhipin.com/wapi/zpCommon/data/getCityShowPosition"
posi=geturl.download(urls2)
position=json.loads(posi)
# print(position)

serial=position["zpData"]["position"]
# print(type(serial))
with open("pois-code.csv", "w", encoding='utf-8') as f:
    csvwriter = csv.writer(f)
    headers=["职位","编号"]
    csvwriter.writerow(headers)
    for dataserial in serial:
        # print(dataserial)
        datatext=dataserial["subLevelModelList"]
        # print(datatext)
        for datatext2 in datatext:
            datatext3=datatext2["subLevelModelList"]
            # print(datatext3)
            for datatext4 in datatext3:
                # print(datatext4["code"],datatext4["name"])
                zw=datatext4["name"]
                bh=datatext4["code"]
                r_data=[zw,bh]
                csvwriter.writerow(r_data)
        # print("==========分隔符==============")

